//
//  CZMainViewController.swift
//  swift微博01
//
//  Created by 张文文 on 15/12/16.
//  Copyright © 2015年 张文文. All rights reserved.
//

import UIKit

class CZMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let mainTabbar = CZMainTabbar()
        setValue(mainTabbar, forKey: "tabBar")
        //设置tabbar字体和图片颜色
//        self.tabBar.tintColor = UIColor.redColor()
        
        //首页
        let homeVC = CZHomeViewController()
        self.addChildVC(homeVC, title: "首页", image: "tabbar_home")

        //消息 
        let messVC = CZMessageViewController()
        self.addChildVC(messVC, title: "消息", image: "tabbar_message_center")
        
        //发现
        let discVC = CZDiscoveryViewController()
        self.addChildVC(discVC, title: "发现", image: "tabbar_discover")
        
        //个人
        let proVc = CZProfileViewController()
        self.addChildVC(proVc, title: "个人", image: "tabbar_profile")
        
            }

    func addChildVC(controller : UIViewController,title : String,image : String){
    
        let proVc = controller
        self.addChildViewController(UINavigationController(rootViewController: proVc))
        proVc.title = title
        proVc.tabBarItem.image = UIImage(named: image)
        let highlightImage = image + "_highlighted"
        proVc.tabBarItem.selectedImage = UIImage(named: highlightImage)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        proVc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: UIControlState.Selected)

    }


}
